package com.graduate.daydayup.room

import androidx.room.*

@Dao
interface ScheduleDao {
    //如果是查询
    @Query("SELECT * FROM  Schedule ")
    fun getAll(): MutableList<Schedule>?

    @Query("SELECT * FROM  Schedule Where name = :name ")
    fun getAllByName( name:String?): Schedule

    @Query("SELECT * FROM  Schedule Where id = :id ")
    fun getAllById( id:Int?): Schedule

    @Query("SELECT * FROM  Schedule Where day = :day ")
    fun getAllByDay( day:Int?): MutableList<Schedule>?

    @Query("SELECT * FROM  Schedule Where day = :day AND name=:name")
    fun getAllByDayAndName( day:Int?,name:String): Schedule

    @Query("DELETE FROM Schedule ")
    fun deleteAllBy()

    @Query("DELETE FROM Schedule WHERE id= :id")
    fun deleteAllById( id:String?)

    @Insert
    fun addSchedule(schedule:Schedule)

    @Update
    fun updateSchedule(schedule :Schedule)

    @Delete
    fun deleteBySchedule(schedule :Schedule)
}